import {Component} from '@angular/core';
import {AgRendererComponent} from '@ag-grid-community/angular';
import {ICellRendererParams} from '@ag-grid-community/core';
import { dateFormat, exists } from '../../../utils/utils';
import {UtilsService} from "@core/services/expression/utils.service";

@Component({
  selector: 'apes-render-time',
  template: `
    {{this.formatterValue(params.value)}}
   `,
  styles: []
})
export class ApesRenderTimeComponent implements AgRendererComponent {
  value:any;
  params: ICellRendererParams;
  constructor(private utils:UtilsService) { }
  refresh(params: any): boolean {
    return false;
  }
  agInit(params: ICellRendererParams): void {
    this.params = params;
  }

  formatterValue(params){
    let value ="";
    if (! exists(params)) return "";
    value =  this.utils.dateFormat("HH:mm",new Date(params));
    return value;
  }

}
